<?php
include_only();

//echo $title;
//echo $language_from;
//echo $language_to;
//echo $public;
//echo $request;

if(empty($save_options)){$save_options='';}
if(empty($original_language)){$original_language='';}
if(empty($new_language)){$new_language='';}
if(empty($request_info)){$request_info='';}
if(empty($public_info)){$public_info='';}

if($save_options=='yes')
{
mysql_query("UPDATE `subtitles` SET `title` = '$title',`language` = '$language_to',`public` = '$public',`request` = '$request',`original_language` = '$language_from' WHERE `id` = $subtitle_id LIMIT 1 ;");
}

?>

<?php
$subtitle_information = get_subtitle_info($subtitle_id);
$video_info = get_video_information($subtitle_information['video_id']);
$video_name =$video_info['name'];
//print_r($video_info);
$all_language = get_all_languages();

for ($i = 0; $i <= count($all_language)-1; $i++) {
if($all_language[$i]['id']==$subtitle_information['original_language']) { $selected='selected="selected"'; } else { $selected=''; }
    $original_language = $original_language . "<option value='".$all_language[$i]['id']."' ".$selected.">".$all_language[$i]['name']."</option>";
}

for ($i = 0; $i <= count($all_language)-1; $i++) {
if($all_language[$i]['id']==$subtitle_information['language']) { $selected='selected="selected"'; } else { $selected=''; }
    $new_language = $new_language . "<option value='".$all_language[$i]['id']."' ".$selected.">".$all_language[$i]['name']."</option>";
}

//print_r($subtitle_information);

if($subtitle_information['public']=='0') {$yes=''; $no='selected="selected"';} else {$yes='selected="selected"'; $no='';}
$public_info = $public_info . "<option value='0' ".$no.">NO</option>";
$public_info = $public_info . "<option value='1' ".$yes.">YES</option>";

if($subtitle_information['request']=='0') {$yes=''; $no='selected="selected"';} else {$yes='selected="selected"'; $no='';}
$request_info = $request_info . "<option value='0' ".$no.">NO</option>";
$request_info = $request_info . "<option value='1' ".$yes.">YES</option>";

$subtitle_info = "
<form method='get' action='index.php'>
<table>
<tr>
<td>
<b>Video:</b>
</td>
<td>
".$video_name."
</td>
</tr>
<tr>
<td>
<b>Title:</b>
</td>
<td>
<input type='text' name='title' value='".$subtitle_information['title']."'/>
</td>
</tr>
<tr>
<td>
<b>Translate From:</b>
</td>
<td>
<select name='language_from'>
<option value='-1'>None</option>
".$original_language."
</select>
</td>
</tr>
<tr>
<td>
<b>Translate To:</b>
</td>
<td>
<select name='language_to'>
".$new_language."
</select>
</td>
</tr>
<tr>
<td>
<b>Public:</b>
</td>
<td>
<select name='public'>
".$public_info."
</select>
</td>
</tr>
<tr>
<td>
<b>Request:</b>
</td>
<td>
<select name='request'>
".$request_info."
</select>
</td>
</tr>
<tr>
<td>
<br>
<input type='submit' name='save' value='save subtitle'/>
<input type='hidden' name='page' value='edit_subtitle_info'/>
<input type='hidden' name='subtitle_id' value='".$subtitle_id."'/>
<input type='hidden' name='save_options' value='yes'/>
</td>
<td></td>
</tr>
</table>
</form>
";
?>